#include "file.h"

#include <cstdarg>

file::file(): content(NULL){}
file::~file(){
    fclose(content);
}
bool file::open(char* fname,const char* mode){
    if( content ) fclose(content);
    return (content = fopen(fname,mode));
}
bool file::opened(){ return content; }
bool file::eof(){ return feof(content); }
size_t file::read(void* dest,size_t size,size_t count){
    return fread(dest,size,count,content);
}
size_t file::write(void* source,size_t size,size_t count){
    return fwrite(source,size,count,content);
}
int file::seek(long int offset,int origin){
    return fseek(content,offset,origin);
}
long int file::tell(){
    return ftell(content);
}
void file::rewind(){
    fseek(content,0,SEEK_SET);
}
int file::fscanf(const char* format,...){
    va_list vl;
    va_start(vl,format);
    return vfscanf(content,format,vl);
}
